<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>post带参数发送方式</title>
</head>
<body>
	<button id='but'>post带参数</button>

	<script type="text/javascript">

	var but = document.getElementById('but');

	but.onclick = function()
	{
		//创建对象
		var x = new XMLHttpRequest;

		x.onreadystatechange = function()
		{

			if(x.readyState == 4 && x.status == 200){

				console.log(x.responseText);
			}
		}


		//3.初始化
		x.open('POST','4.php',true);

		x.setRequestHeader('content-type','application/x-www-form-urlencoded');

		//4.发送
		x.send('a=100&b=200');
	}


	</script>
</body>
</html>